home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / clue.lha / clue / doc / clue.tex / node159_mn.html < prev    next >
Text File  |  1989-07-12  |  9KB  |  220 lines

  1.  
  2. <H3><A ID="SECTION004511100000000000000"><tex2html_anchor_invisible_mark></A> <A ID="ch:event-translation"><tex2html_anchor_mark></A><BR>
  3. Event Translation
  4. </H3><#5137#>
  5.            
  6.       
  7.  
  8.  
  9. <P>
  10. <A ID="2013"><tex2html_anchor_invisible_mark></A>
  11. If an input event is received by a specific window, then that window is given as
  12. a slot value in the corresponding <#2014#><TT>event</TT><#2014#> object. CLUE begins by determining
  13. the contact corresponding to the event window and  calling the contact's
  14. <#2015#><TT>handle-event</TT><#2015#> method. 
  15. <A ID="2016"><tex2html_anchor_invisible_mark></A>
  16. Subsequent contact event processing
  17. involves ``translating'' the event into calls to the appropriate
  18. actions<A ID="2017"><tex2html_anchor_invisible_mark></A> and is controlled by the contact's <#2018#><TT>event-translations</TT><#2018#> slot and its class event translations.
  19. <A ID="2019"><tex2html_anchor_invisible_mark></A><A ID="2020"><tex2html_anchor_invisible_mark></A>
  20.  
  21. <P>
  22. The <#2021#><TT>event-translations</TT><#2021#> slot contains a lookup
  23. table<A NAME="tex2html223" HREF="#footfnm1" TARGET="footer"><SUP>42.1</SUP></A>
  24. whose elements
  25. are <#2023#><B>event translations</B><#2023#><A ID="2024"><tex2html_anchor_invisible_mark></A>. Each event
  26. translation is a list of the form <#4362#><TT>(<#2025#><EM>event-specification</EM><#2025#> <#2026#><EM>name*</EM><#2026#>)</TT><#4362#>,
  27. where each <#2027#><EM>name</EM><#2027#> is either an action name or a list of
  28. the form <#4363#><TT>(<#2028#><EM>action-name argument*</EM><#2028#>)</TT><#4363#> . 
  29. Thus, each event translation in <#2029#><TT>event-translations</TT><#2029#> associates  an event
  30. specification with one or more actions and, 
  31. for each action, an optional argument
  32. list.  The event translations in a contact's <#2030#><TT>event-translations</TT><#2030#> slot can
  33. be modified by the functions <#2031#><TT>add-event</TT><#2031#> and <#2032#><TT>delete-event</TT><#2032#>.
  34. <A ID="2033"><tex2html_anchor_invisible_mark></A><A ID="2034"><tex2html_anchor_invisible_mark></A>  
  35.  
  36. <P>
  37. <#2035#><B>Class event translations</B><#2035#><A ID="2036"><tex2html_anchor_invisible_mark></A> are event translations which
  38. belong to all instances of a contact class. A class event translation is created by
  39. the <#2037#><TT>defevent</TT><#2037#> macro.<A ID="2038"><tex2html_anchor_invisible_mark></A>
  40.  
  41. <P>
  42. Basic contact event processing consists of the following steps:
  43.  
  44. <UL>
  45. <LI>For each event translation in the contact's <#2040#><TT>event-translations</TT><#2040#>:
  46.  
  47. <UL>
  48. <LI>The event is matched with the event specification found in the event
  49. translation. Matching is done using the match function for the event type defined by
  50. the event specification.<A ID="2042"><tex2html_anchor_invisible_mark></A>
  51. </LI>
  52. <LI>If a match occurs, then each of
  53. the actions in the event translation is called and event processing terminates.
  54. Any arguments from the matching event translation are given to the actions.
  55. </LI>
  56. </UL>
  57. </LI>
  58. <LI>If no match is found in the previous step, then the contact's class event
  59. translations are examined. Starting with the class of the contact, then for each
  60. class event translation of the class: 
  61.  
  62. <UL>
  63. <LI>The event is matched against the event specification found in the class
  64. event translation. 
  65. </LI>
  66. <LI>If a match occurs, then each of
  67. the actions in the event translation is called, using any arguments given, and 
  68. event processing terminates.
  69. </LI>
  70. </UL>
  71. </LI>
  72. <LI>If no match is found, then the previous step is repeated for the next
  73. class in the class precedence list.  
  74. </LI>
  75. </UL>
  76.  
  77. <P>
  78. This method of structuring contact event processing allows a user and a contact
  79. programmer to cooperate in defining a contact's input behavior.
  80. Event translations are a contact resource; they can be read from a
  81. user-defined resource
  82. database<A ID="2047"><tex2html_anchor_invisible_mark></A> and used to initialize a contact's <#2048#><TT>event-translations</TT><#2048#> when
  83. the contact is created (see Chapter~<A HREF=<tex2html_cr_mark>#ch:resource-management#2049><tex2html_cr_mark></A>
  84. for a complete discussion of contact resource management). Event translations
  85. express user preferences for the mapping between input events and 
  86. actions. On the other hand, only the contact programmer can determine the
  87. methods which actually implement the actions.
  88. The contact programmer can also provide class event translations to define default
  89. input behavior shared by all instances of a contact class.
  90.  
  91. <P>
  92. <A ID="2050"><tex2html_anchor_invisible_mark></A><A ID="2051"><tex2html_anchor_invisible_mark></A>
  93. Most types of events can be received by a contact only if they are selected by
  94. the contact's <#2052#><TT>event-mask</TT><#2052#>.  CLUE automatically initializes a contact's <#2053#><TT>event-mask</TT><#2053#> slot to select all event types referenced by its <#2054#><TT>event-translations</TT><#2054#> slot and its class event translations.  The <#2055#><TT>event-mask</TT><#2055#>
  95. is also modified appropriately by <#2056#><TT>add-event</TT><#2056#> and <#2057#><TT>delete-event</TT><#2057#>.
  96. As a result, CLUE programmers rarely need to modify a contact's <#2058#><TT>event-mask</TT><#2058#>
  97. slot directly.
  98.  
  99. <P>
  100. CLUE initiates contact event processing by calling the contact's <#2059#><TT>handle-event</TT><#2059#> method.  By default, this method simply processes an event
  101. according to the contact's event translations and class event
  102. translations. 
  103. However, some
  104. contact classes may redefine the <#2060#><TT>handle-event</TT><#2060#> method in order to add input processing unrelated to event
  105. translations.
  106. <#2061#><TT>handle-event</TT><#2061#> calls <#2062#><TT>translate-event</TT><#2062#> in order to determine
  107. which actions will be invoked.
  108.  
  109. <P>
  110. <#4678#>
  111. <#4364#><FONT SIZE="+1"><#2063#><B>handle-event Method, contact</B><#2063#></FONT><#4364#>
  112. <A ID="2064"><tex2html_anchor_invisible_mark></A>
  113. <A ID="2065"><tex2html_anchor_invisible_mark></A>
  114. <DIV class="RIGHT">
  115. <tex2html_image_mark>#tex2html_wrap_inline10106#
  116. </DIV><#4678#>
  117.  
  118. <P>
  119. <DIV class="RIGHT">
  120. <tex2html_image_mark>#tex2html_wrap_inline10109#
  121. </DIV>
  122.  
  123. <P>
  124. <#4679#>
  125. <#4367#><FONT SIZE="+1"><#2078#><B>translate-event Function, contact</B><#2078#></FONT><#4367#>
  126. <A ID="2079"><tex2html_anchor_invisible_mark></A>
  127. <A ID="2080"><tex2html_anchor_invisible_mark></A>
  128. <DIV class="RIGHT">
  129. <tex2html_image_mark>#tex2html_wrap_inline10110#
  130. </DIV><#4679#>
  131.  
  132. <P>
  133. <DIV class="RIGHT">
  134. <tex2html_image_mark>#tex2html_wrap_inline10113#
  135. </DIV>
  136.  
  137. <P>
  138. <#4680#>
  139. <#4370#><FONT SIZE="+1"><#2092#><B>add-event Function, contact</B><#2092#></FONT><#4370#> 
  140. <A ID="2093"><tex2html_anchor_invisible_mark></A> 
  141. <A ID="2094"><tex2html_anchor_invisible_mark></A>
  142. <DIV class="RIGHT">
  143. <tex2html_image_mark>#tex2html_wrap_inline10114#
  144. </DIV><#4680#>
  145.  
  146. <P>
  147. <DIV class="RIGHT">
  148. <tex2html_image_mark>#tex2html_wrap_inline10117#
  149. </DIV>
  150.  
  151. <P>
  152. <#4682#>
  153. <#4373#><FONT SIZE="+1"><#2109#><B>delete-event Function, contact</B><#2109#></FONT><#4373#>
  154. <A ID="2110"><tex2html_anchor_invisible_mark></A> 
  155. <A ID="2111"><tex2html_anchor_invisible_mark></A>
  156. <DIV class="RIGHT">
  157. <tex2html_image_mark>#tex2html_wrap_inline10118#
  158. </DIV><#4682#>
  159.  
  160. <P>
  161. <DIV class="RIGHT">
  162. <tex2html_image_mark>#tex2html_wrap_inline10121#
  163. </DIV>
  164.  
  165. <P>
  166. <#4683#>
  167. <#4376#><FONT SIZE="+1"><#2122#><B>event-actions Function, contact</B><#2122#></FONT><#4376#>
  168. <A ID="2123"><tex2html_anchor_invisible_mark></A> 
  169. <A ID="2124"><tex2html_anchor_invisible_mark></A>
  170. <DIV class="RIGHT">
  171. <tex2html_image_mark>#tex2html_wrap_inline10122#
  172. </DIV><#4683#>
  173.  
  174. <P>
  175. <DIV class="RIGHT">
  176. <tex2html_image_mark>#tex2html_wrap_inline10125#
  177. </DIV>
  178.  
  179. <P>
  180. <#4685#>
  181. <#4379#><FONT SIZE="+1"><#2143#><B>defevent Macro</B><#2143#></FONT><#4379#> 
  182. <A ID="2144"><tex2html_anchor_invisible_mark></A>
  183. <A ID="2145"><tex2html_anchor_invisible_mark></A><A ID="2146"><tex2html_anchor_invisible_mark></A>
  184. <DIV class="RIGHT">
  185. <tex2html_image_mark>#tex2html_wrap_inline10126#
  186. </DIV><#4685#>
  187.  
  188. <P>
  189. <DIV class="RIGHT">
  190. <tex2html_image_mark>#tex2html_wrap_inline10130#
  191. </DIV>
  192.  
  193. <P>
  194. <#4382#><FONT SIZE="+1"><#2158#><B>undefevent Macro</B><#2158#></FONT><#4382#> 
  195. <A ID="2159"><tex2html_anchor_invisible_mark></A>
  196. <DIV class="RIGHT">
  197. <tex2html_image_mark>#tex2html_wrap_inline10131#
  198. </DIV>
  199.  
  200. <P>
  201. <DIV class="RIGHT">
  202. <tex2html_image_mark>#tex2html_wrap_inline10132#
  203. </DIV>
  204.  
  205. <P>
  206. <#4687#>
  207. <#4385#><FONT SIZE="+1"><#2172#><B>describe-event-translations Function</B><#2172#></FONT><#4385#> 
  208. <A ID="2173"><tex2html_anchor_invisible_mark></A>
  209. <DIV class="RIGHT">
  210. <tex2html_image_mark>#tex2html_wrap_inline10133#
  211. </DIV><#4687#>
  212.  
  213. <P>
  214. <DIV class="RIGHT">
  215. <tex2html_image_mark>#tex2html_wrap_inline10135#
  216. </DIV>
  217.  
  218. <P>
  219.  
  220.  =0 <#5147#>=0 <#5151#>